#!/bin/bash
tree_dir="$1"

[[ -n "${tree_dir}" ]] || tree_dir='./'

if [[ ! -d "${tree_dir}" ]];then
  echo "${tree_dir} is not a directory"
  exit 1
else
  for df_list in $(find ${tree_dir} 2> /dev/null | sort)
  do
    df_name="${df_list##*/}"
    df_sign=$(echo ${df_list} | sed 's#[^/]*/#|__ #g' | sed -e 's#__ |#  |#g' -e "s#${df_name}##g")
    df_prot=$(ls -ld ${df_list} | awk '{print $1}')

    printf "${df_sign}[${df_prot}] ${df_list}\n"
  done
fi

